
import {doPostToObj, doPostParam} from '@/services/http'
import modelExtend from '@/utils/modelExtend';
import HttpModel from './http';

let mailManage = {
  namespace: 'mailManage',
  state: {
  },
  effects: {
    *getList ({ payload, callback }, { call, put }) {
      yield put({
        type: 'save',
        payload: { loading: true },
      })
      const response = yield call(doPostParam, payload)
      // console.log(response)
      yield put({
        type: 'save',
        payload: {
          loading: false,
          rows: response.data?.rows,
          pagination: response.data?.pagination
        },
      })
      if (callback) callback(response);
      return response;
    },
  },
  reducers: {
    save (state, action) {
      return {
        ...state,
        ...action.payload,
      }
    },
  },
}
mailManage = modelExtend(HttpModel, mailManage);
export default mailManage;